﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace TuKu
{
    public static class DataBindClass
    {
        /// <summary>
        /// 绑定大类到ListBox
        /// </summary>
        /// <param name="listGroup"></param>
        public static void GroupBind(System.Windows.Forms.ListBox listGroup)
        {
            listGroup.Items.Clear();
            DataTable dt = new BLL.Group().GetList(" 1=1 order by OrderID ").Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                listGroup.Items.Add(dr["title"].ToString().Trim());
            }
        }
        public static void GroupBind(System.Windows.Forms.ComboBox listGroup)
        {
            listGroup.Items.Clear();
            DataTable dt = new BLL.Group().GetList(" 1=1 order by OrderID ").Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                listGroup.Items.Add(dr["title"].ToString().Trim());
            }
        }
        public static void subGroupBind(int groupid, System.Windows.Forms.ListBox listBoxSubGroup)
        {
            listBoxSubGroup.Items.Clear();
            DataTable dt = new BLL.subGroup().GetList(" groupid=" + groupid+" order by addtime").Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                listBoxSubGroup.Items.Add(dr["title"].ToString().Trim());
            }
        }
        public static void subGroupBind(int groupid, System.Windows.Forms.ComboBox ComboBoxSubGroup)
        {
            ComboBoxSubGroup.Items.Clear();
            DataTable dt = new BLL.subGroup().GetList(" groupid=" + groupid + " order by addtime").Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                ComboBoxSubGroup.Items.Add(dr["title"].ToString().Trim());
            }
        }
        public static void subGroupBind(int groupid, System.Windows.Forms.ListBox listBoxSubGroup,string type)
        {
            listBoxSubGroup.Items.Clear();
            DataTable dt = new BLL.subGroup().GetList(" groupid=" + groupid + " order by "+type).Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                listBoxSubGroup.Items.Add(dr["title"].ToString().Trim());
            }
        }
        public static void subGroupBind(int groupid, System.Windows.Forms.ComboBox ComboBoxSubGroup,string type)
        {
            ComboBoxSubGroup.Items.Clear();
            DataTable dt = new BLL.subGroup().GetList(" groupid=" + groupid + " order by "+type).Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                ComboBoxSubGroup.Items.Add(dr["title"].ToString().Trim());
            }
        }
        
    }
}
